#!/usr/bin/python
# -*- coding: UTF-8 -*-
import time
import sys
import gzip
import os

file_name = 'scmp-charging.2024-04-03-19.log.gz'
start_minute = '19:20'
end_minute = '19:28'

start_line = 0
end_line = 0

try:
    with gzip.open(file_name, 'rt', encoding='utf-8') as f:
        count = 0
        # file_content = f.read()
        for line in f:
            count += 1
            if line.startswith('S|') and (f' {start_minute}:' in line):
                if start_line == 0:
                    start_line = count
            if line.startswith('S|') and (f' {end_minute}:' in line):
                end_line = count
except Exception as err:
    print(err)

try:
    with gzip.open(file_name, 'rt', encoding='utf-8') as f:
        # file_content = f.read()
        print(start_line)
        print(end_line)
        count = 0
        for line in f:
            count += 1
            if start_line <= count <= end_line:
                print(line)
except Exception as err:
    print(err)
